package abg.core.mapper;

import abg.core.domain.db.MtRoom;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.ibatis.annotations.Update;

public interface MtRoomMapper extends ZBMapper<MtRoom> {


    default String getMtUserId(String mtId) {
        MtRoom mtRoom = selectOneByQuery(QueryWrapper.create().select("user_id").where("id=?", mtId));
        return mtRoom.getUserId();
    }

    @Update("UPDATE mt_room SET now_zan_count = now_zan_count + #{zanCount},now_hot_count = now_hot_count + #{hotCount} WHERE id=#{mtId}")
    void addHotZan(String mtId, int hotCount, int zanCount);

    @Update("UPDATE mt_room SET now_hot_count = now_hot_count + #{hotCount} WHERE id=#{mtId}")
    void addHot(String mtId, int hotCount);

    default void closeMtByUserId(String userId) {
        QueryWrapper wrapper = QueryWrapper.create().eq("user_id", userId).eq("meeting_status", "0");
        MtRoom mtRoom = new MtRoom();
        mtRoom.setMeetingStatus("1");
        updateByQuery(mtRoom, wrapper);
    }
}